﻿using System.Collections.Generic;
using System.ComponentModel;

namespace SilverPop.UI.Domain
{
	public class NotePage
	{
		private readonly IList<Note> _notes = new List<Note>();

		public string Title { get; set; }

		public IEnumerable<Note> Notes
		{
			get
			{
				return _notes;
			}
		}

		public Note AddNewNote(double x, double y)
		{
			Note n = new Note
			{
				X = x - 75.0d,
				Y = y - 50d,
				W = 150d,
				H = 100d,
				Text = "New note"
			};

			_notes.Add(n);
			return n;
		}
	}

	public class Note : INotifyPropertyChanged
	{
		private string _text;
		private double _x;
		private double _y;
		private double _w;
		private double _h;
		private double _angle;

		public string Text
		{
			get
			{
				return _text;
			}
			set
			{
				_text = value;
				FirePropertyChanged("Text");
			}
		}

		public double X
		{
			get { return _x; }
			set { _x = value; FirePropertyChanged("X"); }
		}
		public double Y
		{
			get { return _y; }
			set { _y = value; FirePropertyChanged("Y"); }
		}
		public double W
		{
			get { return _w; }
			set { _w = value; FirePropertyChanged("W"); }
		}
		public double H
		{
			get { return _h; }
			set { _h = value; FirePropertyChanged("H"); }
		}

		public double Angle
		{
			get { return _angle; }
			set { _angle = value; FirePropertyChanged("Angle"); }
		}


		protected void FirePropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}

		public event PropertyChangedEventHandler PropertyChanged;
	}
}
